package com.example.blue.musicplay.adapter;

import android.content.Context;


import android.support.v7.widget.RecyclerView;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;

import com.example.blue.musicplay.R;
import com.example.blue.musicplay.pool.ObjectPool;

/**
 * Created by blue on 2016/9/23.
 */

public class Online_Layout_adapter extends BaseAdapter {
    private LayoutInflater mInflater;
    public String online_layout_girdView = "online_layout_girdView";
    private Context context;
    private int[] layout_ID = new int[]{R.layout.online_layout_top_grid, R.layout.online_layout_middle};

    public Online_Layout_adapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return layout_ID.length;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(layout_ID[position], null);
            holder = new ViewHolder();
            if (position == 0) {
                holder.gridView = (GridView) view.findViewById(R.id.gridview);
            } else if (position == 1) {
                holder.online_menu_btn_hot = (Button) view.findViewById(R.id.online_menu_btn_hot);
                holder.online_menu_btn_internet_music = (Button) view.findViewById(R.id.online_menu_btn_internet_music);
                holder.online_menu_btn_new = (Button) view.findViewById(R.id.online_menu_btn_new);
            }
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        if (position == 0) {
            Online_GridView_Adapter adapter = new Online_GridView_Adapter(context);
            holder.gridView.setAdapter(adapter);
            ObjectPool.getInstance().creatObject(online_layout_girdView, holder.gridView);
        } else if (position == 1) {

        }
        return view;
    }

    private class ViewHolder {

        GridView gridView;
        Button online_menu_btn_hot;
        Button online_menu_btn_new;
        Button online_menu_btn_internet_music;
    }
}
